using System;
using System.Data;
using System.Collections.Generic;
using System.Data.SqlClient;

namespace DataAccess
{
    public class tbPosts : Popular
    {

        public int PostsID { get; set; }
        public string Title { get; set; }
        public string Intro { get; set; }
        public string Content { get; set; }
        public int AuthorID { get; set; }
        public int? UpdateAuthorID { get; set; }
        public string ImagePath { get; set; }
        public int Active { get; set; }
        public int TypePosts { get; set; }
        public string Note { get; set; }
        public int NumRead { get; set; }
        public DateTime CreatedDate { get; set; }
        public DateTime? UpdatedDate { get; set; }
        public int? PostsCatID { get; set; }
        public int OrgID { get; set; }

        Common<tbPosts> cm = new Common<tbPosts>();
        public bool Insert(Popular b)
        {
            return cm.Insert(b as tbPosts, "sp_tbPosts_Insert");
        }
        public bool Update(Popular b)
        {
            return cm.UpDate(b as tbPosts, "sp_tbPosts_Update");
        }
        public bool Delete(object b)
        {
            return cm.Delete(b, "sp_tbPosts_Delete");
        }
        public IDataReader Select_ID(object b)
        {
            return cm.Select_ID(b, "sp_tbPosts_SelectByID");
        }
        public IDataReader Select_Name(object b)
        {
            return cm.Select_Name(b, "sp_tbPosts_SelectByName");
        }
        public IDataReader SelectAll()
        {
            return cm.Select_All("sp_tbPosts_SelectAll");
        }

        public List<tbPosts> SelectNews()
        {
            return Core.CBO.FillCollection<tbPosts>(Core.DataProvider.Instance.ExecuteReader("sp_tbPosts_SelectNews"));
        }
        public List<tbPosts> SelectAllByOrg(int orgid)
        {
            return Core.CBO.FillCollection<tbPosts>(Core.DataProvider.Instance.ExecuteReader("sp_tbPosts_SelectAllByOrg", orgid));
        }
        public List<tbPosts> SelectNewsByOrg(int orgid)
        {
            return Core.CBO.FillCollection<tbPosts>(Core.DataProvider.Instance.ExecuteReader("sp_tbPosts_SelectNewsByOrg", orgid));
        }
        public List<tbPosts> SelectNewsByOrgCategory(int orgid, int categoryid)
        {
            return Core.CBO.FillCollection<tbPosts>(Core.DataProvider.Instance.ExecuteReader("sp_tbPosts_SelectNewsByOrgCategory", orgid, categoryid));
        }
        public List<tbPosts> SelectNoticeByOrg(int orgid)
        {
            return Core.CBO.FillCollection<tbPosts>(Core.DataProvider.Instance.ExecuteReader("sp_tbPosts_SelectNoticeByOrg", orgid));
        }
    }
}